% Run Tower of Psych and Snow Dots unit tests, under a few configurations.
function repeatAllDotsTests

% keep track of test outuput in a "diary" file
cd('~')
diaryFile = [mfilename, '.txt'];
if exist(diaryFile)
    delete(diaryFile);
end
diary(diaryFile);
diary('on')

try
    % run the Tower of Psych tests, once
    clear all global
    clear classes
    clear mex
    cd(topsRoot);
    passed = topsRunTests();
    assert(passed, 'tops tests failed')
    
    % run the Snow Dots tests with no client or server mode
    clear all global
    clear classes
    clear mex
    cd(dotsRoot);
    passed = dotsRunTests( ...
        'singletonReset', {'clientMode', false, 'serverMode', false})
    assert(passed, 'dots local tests failed')
    
    % run the Snow Dots tests with both client and server mode
    clear all global
    clear classes
    clear mex
    cd(dotsRoot);
    passed = dotsRunTests( ...
        'singletonReset', {'clientMode', true, 'serverMode', true})
    assert(passed, 'dots self delegation tests failed')
    
    % run the Snow Dots tests with a client on this machine and server in a
    % separate Matlab instance
    clear all global
    clear classes
    clear mex
    input('Start the server, please.', 's')
    cd(dotsRoot);
    passed = dotsRunTests(...
        'filePause', .1, ...
        'singletonReset', {'clientMode', true, 'serverMode', false})
    assert(passed, 'dots remote delegation tests failed')
    
catch err
    err
end

diary('off')